package interfaces;

import Script.Offset;

/**
 * Represents a single pointer in the game.
 * Note that no values stored or used take
 * game headers into consideration, header
 * data must be added/subtracted outside
 * the object before usage.
 * 
 * @author Tobias Edin
 */
public interface Pointer extends Comparable<Pointer> {
	
	/**
	 * Get the byte position this pointer points
	 * at in the game file. Note that pointers
	 * who's size prevents them from giving
	 * the full adress, only the relevant bytes
	 * are present.
	 * 
	 * eg. a Snes 2 byte pointer that points
	 * at 0D0200 would only store 0200, and
	 * get the text block info from the user.
	 * 
	 * This value is the one that the program uses
	 * when working with text, not the one that
	 * will be printed back to the file. Any values
	 * that are read from the gamefile is expected
	 * to be modified in the constructor before usage.
	 * 
	 * eg. the snes pointer D255 (in the rom) actually
	 * points at 55D2 (assuming no header), so upon 
	 * reading the value D255 into a Snes pointer object, 
	 * it is converted into 55D2 before usage. This method
	 * thus returns 55D2.
	 */
	public Long getValue();
	
	/**
	 * The bytes that should be printed to
	 * the game file.
	 */
	public byte[] printValue();
	
	/**
	 * Update the file offset this pointer
	 * points to. Method must reformat the offset
	 * to match the present pointer format, if
	 * necessary.
	 * @param newValue New offset.
	 */
	public void setValue(Offset newOffset);
	
	/**
	 * Get the value of this pointer as a hexadecimal string.
	 */
	public String hexValue();
	
	/**
	 * Returns the position of this pointer in the pointer table it
	 * was dumped from, relative to the other pointers. The first
	 * pointer in the table will have position 1.
	 */
	public Long getPosition();
	
	/**
	 * Returns the offset of the pointer in the file it was dumped from.
	 */
	public Offset getFileOffset();
	
	/**
	 * Compares this pointers value (that is, the offset it's pointing at)
	 * to another pointer. Compairsons must be made using big endian values.
	 * @return 1 if this pointer is higher than p, 0 if they're equal,
	 * 		   -1 if it's smaller.
	 */
	public int compareTo(Pointer p);
}
